<?php

namespace api\v1\controller;

use api\base\CRestBase;
use think\facade\Db;

class MobilePermissionController extends CRestBase {
    public function setMobilePermission() {
        //[{"permissionName":"获取后台定位权限","status":1,"stepNo":1}]
        //permissionData
        $data = $this->request->getContent();
        $obj = json_decode($data,true);
        $list = base64_decode($obj['permissionData']);
        $arr = json_decode($list,true);
        $time = time();
        $student_id = 'permission_trace';
        foreach ($arr as $id => $permission) {
            $permission['create_time'] = $time;
            $permission['student_id'] = $student_id;
            $arr[$id] = $permission;
        }
        Db::name('permission_trace')->insertAll($arr);
        $this->success("ok");
    }

    public function setPermissionResult(){
        $data = $this->request->getContent();
        $obj = json_decode($data,true);
        //{"permissionResult":"1"}
        $this->success('ok');
    }
}